<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1 , user-scalable=no/">
    <title>个人信息提交</title>
    <link href="/lib/layui-v2.7.3/layui/css/layui.css" rel="stylesheet">
    <link rel="stylesheet" href="/bootstrap/css/bootstrap.min.css">
    <link rel="stylesheet" href="/bootstrap/css/bootstrap-theme.css">
    <link rel="stylesheet" href="/css/theme.css">
    <style>
        .row {
            margin-right: 0px;
            margin-left: 2px;
            margin-top: -68px;
        }
        .fieldset{
            border: 1px solid #ddd;
            padding: 26px;
            margin-left: 0px;
            margin-right: 0px;
            margin-top: 46px;
        }
        .notice{
            width: 170px;
            margin-left: 121px;
        }
        .messageForm{
            white-space:nowrap!important;
        }
        .layui-input-inline{
            margin-left: 40px;
        }
        .layui-btn-normal{
            margin-left: 560px;
        }
        .layui-textarea{
            width: 250px;
            margin-left: 9px;

        }

    </style>
</head>
<body>

<!--这里是头部的导航栏的整体框架-->
<div class="row">
    <img src="../icon/100.jpg" class="img-thumbnail" alt="A generic square placeholder image with a white border around it, making it resemble a photograph taken with an old instant camera">
<!--    <nav class="navbar navbar-default navbar-fixed-top">
        <div class="container">
            <div class="container-fluid">
                <div class="navbar-header">
                    <a class="navbar-brand" href="#"><img src="../images/icon/100.jpg" style="height: 300px;width: 400px"></a>
                </div>
            </div>
        </div>
    </nav>-->
</div>
<fieldset class="fieldset">
    <form class="layui-form messageForm" action="">

        <div class="layui-form-item">
            <label class="layui-form-label" style="width:143px;margin-left: -33px">请输入姓名或昵称</label>
            <div class="layui-input-inline">
                <input type="text" name="usernamecity" lay-verify="required" autocomplete="off" class="layui-input" style="margin-left: 10px;width: 224px;" maxlength="10">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label" style="width:115px;margin-left:-34px">通知接受方式</label>
            <div class="layui-input-block notice" >
                <select name="noticetype" lay-filter="noticetype" lay-verify="required">
                    <option value="">--请选择--</option>
                    <option value="0">手机短信通知</option>
                    <option value="1">邮件通知</option>
                </select>
            </div>
        </div>

        <div id="phoneInput" class="layui-form-item" style="display: none">
            <label class="layui-form-label" style="width:127px;margin-left: -58px">输入手机号</label>
            <div class="layui-input-inline">
                <input type="tel" name="phonenum"  id="phoneNum" autocomplete="off" class="layui-input"  maxlength="11" style="margin-left: 11px">
            </div>
        </div>

        <div id="emailInput" class="layui-form-item" style="display:none">
            <label class="layui-form-label"style="width:127px;margin-left: -64px">请输入邮箱</label>
            <div class="layui-input-inline">
                <input type="text" name="emailnum"  id="emailNum"  autocomplete="off" class="layui-input"  style="margin-left: 10px;width: 224px;" maxlength="20">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label"style="width:128px;margin-left: -33px">请选择服务类型</label>
            <div class="layui-input-block notice" >
                <select name="servicetype" lay-filter="servicetype"lay-verify="required">
                    <option value="">--请选择--</option>
                    <!--<option value="0">全部</option>-->
                    <option value="1">天气变化提醒</option>
                    <option value="2" disabled="">生活指数分析提醒(暂时废弃)</option>
                </select>
            </div>
        </div>


        <div class="layui-form-item">
            <label class="layui-form-label" style="width:154px;margin-left: -35px">提醒时间(24小时制)</label>
            <div class="layui-input-block notice" >
                <select name="timetype" lay-filter="timetype" lay-verify="required">
                    <option value="" >--请选择--</option>
                    <option value="0">(早上)6:00</option>
                    <option value="1">(早上)6:30</option>
                    <option value="2">(早上)7:00</option>
                    <option value="3">(早上)7:20</option>
                    <option value="4">(早上)7:40</option>
                    <option value="5">(早上)8:00</option>
                </select>
            </div>
        </div>
        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label" style="width:129px;margin-left: -35px">您的建议或意见</label>
            <div class="layui-input-block">
                <textarea placeholder="如果您有好的建议或疑问 欢迎吐槽和留言" class="layui-textarea"  maxlength="300" name="remark"></textarea>

            </div>
            <div class="button-form" style="width: 10px;margin-left: -467px;margin-top: 32px;">
                <button class="layui-btn layui-btn-radius layui-btn-normal" style="background: #FFB800" lay-submit lay-filter="formDemo">立即提交</button>
                <button type="reset" class="layui-btn layui-btn-radius layui-btn-primary">重置</button>
            </div>
        </div>
    </form>

</fieldset>
<script src="/lib/layui-v2.7.3/layui/layui.js"></script>
<script src="/js/jquery.min.js"></script>
<script>
    //一般直接写在一个js文件中
    layui.use(['layer', 'form'], function(){
        var layer = layui.layer
            ,form = layui.form;

        //layer.msg('Hello World');
        form.on('select(noticetype)', function(data){
            //console.log(data);
            var value=data.value

            if(value!=''&&value==0){
                $("#phoneInput").css("display","block")
                $("#emailInput").css("display","none");
                 $("#phoneNum").attr("lay-verify","required|phone");
                $("#emailNum").attr("lay-verify","");
                form.render();
            }else if(value==1){
                $("#emailInput").css("display","block");
                $("#phoneInput").css("display","none");
                $("#emailNum").attr("lay-verify","required|email");
                $("#phoneNum").attr("lay-verify","");
                form.render()
            }else{
                $("#emailInput").css("display","none");
                $("#phoneInput").css("display","none");
                $("#phoneNum").attr("lay-verify","");
                $("#emailNum").attr("lay-verify","");
            };
        });

        //监听提交
        form.on('submit(formDemo)', function(data){
            var index = layer.load();
            $.ajax({
                url:'/user/apply',
                method:'post',
                data:data.field,
                dataType:'JSON',
                success:function(res){
                    layer.close(index);
                    if(res.code==0){
                        layer.msg(res.msg,{
                            icon:6
                        },function () {
                            window.location.href="/experice/index";
                        });
                    }else{
                        layer.msg(res.msg,{icon:2})
                    }


                },
                error:function (data) {
                    layer.msg(data.msg);
                    layer.close(index);
                }
            }) ;
            return false;
        });

    });



</script>
</body>
</html>